﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DB.DBUtility;
using MySql.Data.MySqlClient;

namespace DB.DAL
{
    public partial class TPlan
    {
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int tpid, string name)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from TPlan");
            strSql.Append(" where ID != @ID and Name=@Name");
            MySqlParameter[] parameters = {
                    new  MySqlParameter("@ID", MySqlDbType.Int32),
					new MySqlParameter("@Name", MySqlDbType.String)
			};
            parameters[0].Value = tpid;
            parameters[1].Value = name;

            return DbHelperMySQL.Exists(strSql.ToString(), parameters);
        }

        public bool  Delete(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from TPlan ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
